<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
    <head>
        <title>Controller Example</title>
        <style type='text/css'>
            
        </style>
    </head>
    <body>
<div id="demo-html">
<form action='' id='createRecipes'>
	<input type='text' name='name'/>
	<input type='submit' value='Create Recipe'/>
</form>
</div>
<script type='text/javascript' src='../../steal/steal.js'></script>
<script type='text/javascript'>
steal("jquery/controller", 
      "jquery/model",
	  "jquery/dom/form_params",
	  "jquery/dom/fixture",
	  function(){
	  	
$.fixture.delay = 2000;
$.fixture("POST /recipes",function(){
	return {};
})

$.Model('Recipe',{
	create : "/recipes"
},{});

$.Controller('Creator',{
  "{recipe} created" : function(){
    this.update({recipe : new Recipe()});
	this.element[0].reset();
	this.find("[type=submit]").val("Create Recipe")
  },
  "submit" : function(el, ev){
  	ev.preventDefault();
    var recipe = this.options.recipe;
    recipe.attrs( this.element.formParams() );
	this.find("[type=submit]").val("Saving...")
    recipe.save();
  }
});

$('#createRecipes').creator({recipe : new Recipe()})

})
</script>
    </body>
</html>